package com.snowRemovingUser.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.snowRemovingUser.domain.TPredictionAll;
import com.snowRemovingUser.service.ITPredictionAllService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 预测报表历史数据Controller
 * 
 * @author lg
 * @date 2024-04-16
 */
@RestController
@RequestMapping("/snowRemoving/predictionAll")
public class TPredictionAllController extends BaseController
{
    @Autowired
    private ITPredictionAllService tPredictionAllService;

    /**
     * 查询预测报表历史数据列表
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:predictionAll:list')")
    @GetMapping("/list")
    public TableDataInfo list(TPredictionAll tPredictionAll)
    {
        startPage();
        List<TPredictionAll> list = tPredictionAllService.selectTPredictionAllList(tPredictionAll);
        return getDataTable(list);
    }

    /**
     * 导出预测报表历史数据列表
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:predictionAll:export')")
    @Log(title = "预测报表历史数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TPredictionAll tPredictionAll)
    {
        List<TPredictionAll> list = tPredictionAllService.selectTPredictionAllList(tPredictionAll);
        ExcelUtil<TPredictionAll> util = new ExcelUtil<TPredictionAll>(TPredictionAll.class);
        util.exportExcel(response, list, "预测报表历史数据数据");
    }

    /**
     * 获取预测报表历史数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:predictionAll:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tPredictionAllService.selectTPredictionAllById(id));
    }

    /**
     * 新增预测报表历史数据
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:predictionAll:add')")
    @Log(title = "预测报表历史数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPredictionAll tPredictionAll)
    {
        return toAjax(tPredictionAllService.insertTPredictionAll(tPredictionAll));
    }

    /**
     * 修改预测报表历史数据
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:predictionAll:edit')")
    @Log(title = "预测报表历史数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPredictionAll tPredictionAll)
    {
        return toAjax(tPredictionAllService.updateTPredictionAll(tPredictionAll));
    }

    /**
     * 删除预测报表历史数据
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:predictionAll:remove')")
    @Log(title = "预测报表历史数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPredictionAllService.deleteTPredictionAllByIds(ids));
    }
}
